Skip to content

fix: install script to work with non-bash shells (closes #1527)#1550

Closed
aspizu wants to merge 2 commits into
wasm-bindgen:masterfrom
aspizu:master
Closed

fix: install script to work with non-bash shells (closes #1527)#1550
aspizu wants to merge 2 commits into
wasm-bindgen:masterfrom
aspizu:master

Conversation

@aspizu
Copy link
Copy Markdown

@aspizu aspizu commented Feb 8, 2026

guybedford added a commit that referenced this pull request May 13, 2026
…ION (#1578)

Two bugs broke `curl https://wasm-bindgen.github.io/wasm-pack/installer/init.sh -sSf | sh`:

1. The arg-parsing block introduced in 15e4f4f used bash arrays
   (`ORIG_ARGS=("$@")` / `"${ORIG_ARGS[@]}"`), so any non-bash POSIX
   shell (dash, ash, BusyBox sh) failed with a syntax error. This is
   issue #1527.

2. `docs/_installer/build-installer.rs` does a literal `$VERSION` ->
   `vX.Y.Z` text replacement on the script. Since 15e4f4f also added
   real `$VERSION` shell expansions (`if [ -z "$VERSION" ]`, the
   `case "$VERSION"`, etc.), every one of those got mangled in the
   published artifact, e.g. `if [ -z "v0.14.0" ]` and
   `VERSION="vv0.14.0"`. The runtime --version / VERSION-env override
   has been silently broken in every published release since.

This commit:

* switches the build-time placeholder to `@@WASM_PACK_VERSION@@` so it
  cannot collide with real shell variable references (both in init.sh
  and index.html).
* rewrites init.sh as POSIX sh: no arrays, no `local`, scans args via
  `for _arg in "$@"` without consuming them so they still pass
  through to wasm-pack-init.
* keeps the precedence: explicit `VERSION=` env > `--version X` arg >
  build-time baked version > "latest" (resolved via GitHub API).

Verified syntax-clean and behaviourally correct under dash, /bin/sh,
and bash for piped invocation (`curl ... | sh`), `sh -s -- --version
X`, env override, and arg passthrough.

Supersedes #1550, closes #1527.
@guybedford
Copy link
Copy Markdown
Contributor

Fixed via #1578.

@guybedford guybedford closed this May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Install script does not work using sh, needs bash

2 participants